<script>
export default {
  name: 'commonObj',
  data() {
    return {
      codeIsShow: true
    }
  },
  props: {
    value: [Object, Array, String, Number],
    dateIsShow: {
      type: Boolean,
      default: false
    },
    inputIsShow: {
      type: Boolean,
      default: false
    },
    resultsymbolData: {
      type: Array,
      default() {
        return []
      }
    }
  },
  computed: {
    operators: {
      get() {
        return this.value.operatorsVal
      },
      set(val) {
        this.$emit('changeOperators', val)
      }
    },
    conditions2: {
      get() {
        return this.value.conditions2Val
      },
      set(val) {
        this.$emit('changeConditions2', val)
      }
    },
    dates: {
      get() {
        return this.value.datesVal
      },
      set(val) {
        this.$emit('changeDates', val)
      }
    }
  },
  methods: {
    handleSelectOperators() {},
    // eslint-disable-next-line
    renderContent(h) {
      return (
        <div>
          <div class='common-box'>
            <label class='common-label'>请输入运算符 :</label>
            <div class='commonLine'>
              <c-select
                ref='operator'
                value={this.operators}
                on-change={val => {
                  this.operators = val
                }}
                filterable
                placeholder='请输入运算符'
                value-key='s-operator'>
                {this._l(this.resultsymbolData, item => {
                  return (
                    <c-option
                      key={item.objId}
                      label={item.symbolName}
                      value={item.objId}
                    />
                  )
                })}
              </c-select>
            </div>
          </div>

          <div class='common-box' v-show={this.inputIsShow}>
            <label class='common-label'>请输入条件 :</label>
            <div class='commonLine'>
              <c-input
                ref='inputCondition'
                placeholder='请输入条件'
                v-model={this.conditions2}
                value={this.conditions2}
                on-change={val => {
                  this.conditions2 = val
                }}
              />
            </div>
          </div>

          <div class='common-box' v-show={this.dateIsShow}>
            <label class='common-label'>请输入条件 :</label>
            <div class='commonLine'>
              <c-date-picker
                ref='condition'
                value={this.dates}
                on-input={val => {
                  this.dates = val
                }}
                type='date'
                format='yyyy 年 MM 月 dd 日'
                value-format='yyyy-MM-dd'
                placeholder='选择日期时间'
              />
            </div>
          </div>
        </div>
      )
    },
    // eslint-disable-next-line
    renderCustom(h) {
      return this._e()
    }
  },
  // eslint-disable-next-line
  render(h) {
    if (this.codeIsShow) {
      return (
        <div class='code-wrapper'>
          <div>{this.renderContent(h)}</div>
          <div>{this.renderCustom(h)}</div>
        </div>
      )
    }
  },
  mounted() {}
}
</script>

<style lang="scss"></style>
